let loginModule = (function () {
    let $userName = $('.userName'),
        $userPass = $('.userPass'),
        $submit = $('.submit');

    function handle() {
        $submit.click(async function () {
            let account = $userName.val().trim();
            let password = $userPass.val().trim();

            if (account === "" || password === "") {
                alert("账号或密码不能为空，请重新输入");
                return;
            }
            password = md5(password);
            let result = await axios.post("/user/login", {
                account,
                password
            });
            if (parseInt(result.code) === 0) {
                alert('验证通过 即将为您跳转到首页...');
                window.location.href = "index.html";
                return;
            }
            alert('账号密码错误 请重新输入')
        });
    }

    return {
        init() {
            handle();
        }
    }
})();
loginModule.init()